home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Online / Epic4 / share / epic / help / 6_functions / tr < prev    next >
Text File  |  2001-03-21  |  1KB  |  33 lines

  1. Synopsis:
  2.    $tr(/<input>/<output>/<string>)
  3.  
  4. Technical:
  5.    This function "translates" the input characters to the output characters
  6.    in the given string.  Input and output characters are paired up in the
  7.    order they are specified in (first-first, second-second, etc.).  If
  8.    there are more input than output, the last output character will replace
  9.    any input characters that do not have a corresponding output character.
  10.    Any of the arguments may be variables or literal strings.  The delimiter
  11.    does not need to be a '/'; it may be any character not found in the
  12.    input or output characters.
  13.  
  14. Practical:
  15.    This function is useful for doing very simple text encoding, such as
  16.    ROT13.  It is also useful for stripping out unwanted characters from
  17.    untrusted sources (such as shell meta characters).
  18.  
  19. Returns:
  20.    "translated" string
  21.  
  22. Examples:
  23.    /* assume $oldc is "aeiouy" and $newc is "yuoiea" */
  24.    $tr(/s/z/efnet has bots)             returns "efnet haz botz"
  25.    $tr(/$oldc/$newc/efnet has bots)     returns "ufnut hys bits"
  26.    $tr(/$oldc/_/efnet has bots)         returns "_fn_t h_s b_ts"
  27.    $tr(/abc//blah blah)                 effectively the same as $strip()
  28.    $tr(#a#e#blah)                       returns "bleh"
  29.  
  30. See Also:
  31.    sar(6); msar(6); split(6); strip(6)
  32.  
  33.